#ifndef Player_h
#define Player_h

#include <iostream>
#include <string>
#include <osg/Group>
#include <osg/Geode>
#include <osgDB/ReadFile>
#include <osg/NodeVisitor>
#include <osg/PositionAttitudeTransform>
#include <osgGA/GUIEventAdapter>

#include "Engine.h"

class Inventory;
class Cloth;
class Stage;

// Callback class to handle keyboard event
class PlayerPositionCallback : public osg::NodeCallback {

public:
	PlayerPositionCallback(KeyboardState* keyState) {
		m_pkeyState = keyState;
	}
	
	osg::Vec3d getLastPos() { return m_lastPos;} 
	osg::Quat getLastAtt() { return m_lastAtt;} 

	virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);

protected:
	KeyboardState* m_pkeyState;
	osg::Vec3d m_lastPos;
	osg::Quat m_lastAtt;
};

class Player {

public:
	Player();
	~Player();

	void init();
	void update();

	const osg::Vec3d& getPosition() { return m_ptransform->getPosition(); }
	void setPosition(osg::Vec3d& p) { m_ptransform->setPosition(p); }
	void setPositionExclam(osg::Vec3d& p) { m_ptransformExclam->setPosition(p); }

	osg::Node* getPlayerNode() { return player;}
	ComputeBoundingBox &getBoundBox() { return bbox; }  
	PlayerPositionCallback* getPosCallBack() { return m_pposCallback;}

	bool isHidded(){return m_bisHidded;}
	void setHidded(bool bvalue){m_bisHidded = bvalue;}

	inline Inventory* getInventory() {return m_pinventory;}

private:
	osg::PositionAttitudeTransform* m_ptransform;
	osg::PositionAttitudeTransform* m_ptransformExclam;
	KeyboardState* m_pkeyState;
	ComputeBoundingBox bbox;
	Inventory* m_pinventory;
	Cloth* m_pcloth;
	osg::Node* player;
	osg::Node* exclamationMark;

	PlayerPositionCallback *m_pposCallback;
	bool	m_bisHidded;

};


#endif // Player_h
